<?php

namespace Dddxiu\rules;

use Dddxiu\Layer;

/**
 * 单选
 */
class Enum implements Rule
{
    // flag
    const F = 'e';


    /**
     * 单选
     * @param array $input
     * @param string $field
     * @param Layer $layer
     * @param array $args
     * @return \Closure|bool
     * @throws \Exception
     */
    public static function valid($input, $field, $layer, $args)
    {
        $pass = in_array($input[$field], $args);
        if ($pass) {
            return $layer::next();
        }
        return false;
    }
}
